<!DOCTYPE HTML>
<html lang="en-US">
<head>
	<meta charset="UTF-8">
	<title>Login PHP</title>
	<link rel="stylesheet" href="css/style.css" />
	<link href='http://fonts.googleapis.com/css?family=Oleo+Script' rel='stylesheet' type='text/css'>
	<script type="text/javascript" src="js/laypage/laypage.js"></script>
	<script type="text/javascript" src="js/jquery/jquery.min.js"></script>
	<script type="text/javascript">
	
	$(document).ready(function(){
		$("#login").click(function(){
			var action = $("#lg-form").attr('action');
			var form_data = {
				uname: $("#uname").val(),
				upassword: $("#upassword").val(),
				is_ajax: 1
			};
			
			$.ajax({
				type: "POST",
				url: action,
				data: form_data,
				dataType:"json",
				success: function(response)
				{
					console.log(response);
					console.log(response.message);
					var temp=response.message;
					
					if(temp=='success'){
						 location.href='Goods_list.jsp' ;
					}else{
						
						$("#message").html('<p class="error">ERROR: 用户名或密码错误，请重新输入！</p>');
					}
				}	
			});
			return false;
		});
	});
	</script>
	
	
</head>
<body>
	<div class="lg-container">
		<h1>Admin Area</h1>
		<form action="/users/login" id="lg-form" name="lg-form" method="post">
			
			<div>
				<label for="uname">Username:</label>
				<input type="text" name="uname" id="uname" placeholder="uname"/>
			</div>
			
			<div>
				<label for="upassword">Password:</label>
				<input type="upassword" name="upassword" id="upassword" placeholder="upassword" />
			</div>
			
			<div>				
				<button type="button" id="login">Login</button>
			</div>
			
		</form>
		<div id="message"></div>
	</div>
</body>
</html>